home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++
- Subject: Re: what is the proper way to create header files??
- Date: Wed, 10 Jan 1996 13:14:48 GMT
- Organization: Netcom
- Message-ID: <30f3ba2d.383635072@nntp.ix.netcom.com>
- References: <4cv6i3$9dg@news.ios.com>
- NNTP-Posting-Host: ix-dc12-01.ix.netcom.com
- X-NETCOM-Date: Wed Jan 10 5:13:37 AM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- Keith Boruff <kboruff@village.ios.com> wrote:
-
- |>I have spent some time scanning the included header files that came
- with
- |>my compiler (iostream.h, math.h, cstring.h, etc...).
- |>
- |>I have noticed that any functions that can be used from a given
- header
- |>file has only its prototype (declaration) listed. The definitions in
- most
- |>cases are not to be found in the header files themselves.
- |>
- |>I had learned some time ago about creating library files. I heard
- that a
- |>library should contain an interface (header file) and and
- implementation
- |>file. The header file contains all info pertaining to function
- |>declarations and class declarations. The implementation files
- contain the
- |>definitions of any functions. The implementation file is compiled
- |>separately and then linked to any source file that includes the
- |>interface. exam: #include "somefile.h"..
- |>
- |>This is sure the case with all files in my include directory. I
- cannot
- |>figure out how including a header file with function declarations
- will
- |>automatically include the binary file with its corresponding
- definitions.
- |>
- |>The only way that I can achieve a similiar outcome is by linking my
- |>driver file and header binary file together in a project. Yet I do
- not
- |>have to do this with say: iostream.h, cstring.h, ctype.h...ad
- nauseum..
- |>
- |>I would like to be able to do this so that I can hide the ugly
- details of
- |>any function definitions and only expose the programmer to what my
- |>classes, functions offer.
- |>
- |>Could someone tell me how this is achieved? I want to be able to
- include
- |>my own header files into my driver files without the inconvenience
- of
- |>linking two separate files in a project.
- |>
- |>Does this method take some extensive knowledge in knowing
- preprocessor
- |>directives. I have seen these things smeared all over the *.h text
- files.
-
- In most compilers (read: every one I know of) there is no link between
- the header file and the executable. In order to use the header file,
- you must also link in the appropriate object or library files.
-
- Generally, many of the implementor defined headers (including the
- standard headers) declare functions that are contained in standard
- libraries that the compiler always links in.
-
- For example, on UNIX systems you needn't link in any special library
- for most of the standard headers. The one notable exception is
- <math.h>. Most (all?) UNIX compilers do not link in some of the
- floating point math functions unless you explicitly do it with -lm on
- the command line.
-
- PC compilers generally automatically link in all of the standard
- functions and some of the non-standard ones simply because they are in
- a library that is always linked in. In most cases there are also
- non-standard functions that require linking in special libraries
- explicitly.
-
-
- Michael M Rubenstein
-